#encoding: utf-8
from equipment import Equipment
from item import Item

class Storage(object):
    def __init__(self, maxlen=10, name='normalBag'):#创建一个包，默认最大容量为10
        self.items = []
        self.maxlen = maxlen
        self.name = name
        self.owner = None

    def baglimited(self):       #当容量大于最大容量的时候，报错
        if len(self.items) < self.maxlen:
            return True
        return False

    def addItem(self, item):       #判断物品能否让入包内，只有道具和武器可以放入，其他报错
        if isinstance(item,Item) or isinstance(item,Equipment):
            if self.baglimited():
                self.items.append(item)
                return True
        return False
    
    def index(self, item_index):
        return self.items[item_index]
        
    def drop(self, item_index):
        self.items.pop(item_index)

class Bag(Storage):
    pass

class Garage(Storage):
    pass
